<template>
  <div class="app-container">
    <!-- 查询表单 -->
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">

      <el-form-item label="审核员:" prop="shenhe" width="240px">
        <el-input v-model="queryParams.shenhe" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="单据号(czbh):" prop="czbh">
        <el-input v-model="queryParams.czbh" width="240px" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        <!-- 
        <el-button type="warning" 
        plain icon="Download" 
        @click="handleExport"
        v-hasPermi="['system:guozhong:export']">导出</el-button>
        -->
      </el-form-item>
    </el-form>

    <!-- 表格展示 -->
    <el-table v-loading="loading" :data="guozhongList">
      <el-table-column label="发票姓名" align="center" :prop="'gysdm'" />
      <el-table-column label="净重" align="center" :prop="'jz'" />
      <el-table-column label="单价" align="center" :prop="'jsdj'" />
      <el-table-column label="金额" align="center" :prop="'jsje'" />
      <el-table-column label="打款姓名" align="center" :prop="'yhckrxm'" />
      <el-table-column label="打款账号" align="center" :prop="'yhkh'" />
      <el-table-column label="出厂单据号" align="center" :prop="'cmz'" />
      <!-- <el-table-column label="编号" align="center" :prop="'ss'" /> -->
    </el-table>

    <!-- 分页 -->
    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />
  </div>
</template>

<script>
import { listGuozhong, listGuozhongfuhe } from "@/api/system/Fdongbei/fapiao";

export default {
  name: "Guozhong",
  data() {
    return {
      loading: false,
      showSearch: true,
      dateRange: [],
      total: 0,
      guozhongList: [],
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        shenhe: "",
        czbh: ""
      },
      // 表单校验
      // rules: {
      //   czbh: [
      //     {
      //       required: true,
      //       message: "车牌号不能为空",
      //       trigger: "blur"
      //     },
      //     {
      //       validator: this.validateLicensePlate,
      //       trigger: "blur"
      //     }
      //   ]
      // }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    // 获取列表数据
    getList() {
      this.loading = true;
      listGuozhongfuhe(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
        this.guozhongList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },

    // 搜索按钮操作
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },

    // 导出按钮操作
    handleExport() {
      this.download('system/fapiao/export', {
        ...this.queryParams
      }, `guozhong_${new Date().getTime()}.xlsx`)
    },

    // 重置按钮操作
    resetQuery() {
      this.dateRange = []; // 重置时间范围
      this.getList(); // 刷新数据
    }

  }
};
</script>
